R Basics

Short Course on Statistical Programming in R

April 3, 2017

Overview

Today we'll cover:

  • Understanding R & R Studio
  • Objects/Data Structures
  • Packages
  • Data Basics (importing/exporting data, viewing data, subsetting/appending)

The main goal is to get familiar with the R environment.

R in a Nut Shell

R is a statistical and graphical programming language that is based off a much older language called S. It's source code is written in C, Fortran, and R. And it's completely free under a GNU General Public License.

What this means for us:

  • No Barriers to Entry: easy to acquire, easy to contribute
  • Active Community: if you can think it, there is likely a package out there that does it.
  • Powerful and Adaptive: build an estimator from scratch, scrape a web-site, automate the coding of a dataset. All is within one's reach.

Why use R?

R offers a powerful way to

  • analyze data
  • clean excel spreadsheets
  • migrate projects across platforms
  • format and clean text
  • manage any data source
  • produce compelling graphics and maps

.Rdata

.Rdata offers two options to save data. We can either save a single data object, or save the entire workspace

# Save just an object
save(data, file="data.Rdata") 


# Save the entire workspace
save.image(file="workspace.Rdata") 

Applied Example 2

Return to your R Studio session and open importing_data.R.

Further References

There are some great resources out there to help you climb the R learning curve.